/****************************************************************************
 * Copyright (C) 2012 Dj_Skual
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ****************************************************************************/
#ifndef _EXPLORER_H
#define _EXPLORER_H

#include "../GUI/gui.h"
#include "../GUI/gui_pointed.h"
#include "../Browsers/Devices/filebrowser.h"
#include "../Browsers/Devices/IconFileBrowser.hpp"
#include "../Browsers/Devices/ListFileBrowser.hpp"
#include "../Browsers/Saves/savebrowser.h"
#include "../Browsers/Saves/esavebrowser.h"
#include "../Browsers/Saves/IconSaveBrowser.hpp"
#include "../Browsers/Saves/ListSaveBrowser.hpp"
#include "../Browsers/Miis/miibrowser.h"
#include "../Browsers/Miis/emiibrowser.h"
#include "../Browsers/Miis/IconMiiBrowser.hpp"
#include "../Browsers/Miis/ListMiiBrowser.hpp"
#include "../Browsers/GC/gcbrowser.h"
#include "../Browsers/GC/IconGCBrowser.hpp"
#include "../Browsers/GC/ListGCBrowser.hpp"

class Explorer : public GuiFrame, public sigslot::has_slots<>
{
	public:
		static Explorer *Instance() { if(!instance) instance = new Explorer(); return instance; }
		static void DestroyInstance() { delete instance; instance = NULL; }
		
		void show();
		void hide();
		
		void Reload();
		void SwitchDisplayMode() { switchingDisplay = true; Reload(); }
		
		Browser * CurrentBrowser() { return curBrowser; }
		GuiFileBrowser * CurrentGuiBrowser() { return guiBrowser; }
		
	protected:
		Explorer();
		virtual ~Explorer();
		
		static Explorer *instance;
		
		void OnStateChange(GuiElement *sender, int state, int stateChan);
		void OnParentDirBtnClick(GuiButton *sender, int pointer, const POINT &p);
		void OnDeviceBrowserClick(int index);
		void OnSaveBrowserClick(int index);
		void OnMiiBrowserClick(int index);
		void OnGCBrowserClick(int index);
		void OnManageWindowClose(GuiFrame * manageWindow UNUSED) { }
		
		bool switchingDisplay;
		
		FileBrowser *fileBrowser;
		SaveBrowser *saveBrowser;
		ESaveBrowser *esaveBrowser;
		MiiBrowser *miiBrowser;
		EMiiBrowser *emiiBrowser;
		GCBrowser *gcBrowser;
		
		Browser * curBrowser;
		GuiFileBrowser * guiBrowser;
		
		GuiImageData * browserImgData;
		GuiImage * browserImg;
		
		GuiPointed * pointed;
		
		GuiButton * parentDir;
		GuiTrigger trigB;
};

#define CurrentBrowser		Explorer::Instance()->CurrentBrowser
#define CurrentGuiBrowser	Explorer::Instance()->CurrentGuiBrowser

#endif
